#!/bin/bash
cat $1 $2 $3 > all.txt
cat all.txt | sort | awk '{print $1}' > ip.txt

for i in `cat ip.txt`;do
    cat all.txt | grep $i | awk {'print $3,$2,$1'} | sort -n | head -n1  >> sort.txt
done

cat sort.txt | awk '{print $3,$2,$1}' | sort | uniq | awk '{print $3,$2,$1}'|sort -n > end.txt
rm all.txt ip.txt sort.txt -rf
